<?php
if (!defined('IN_ZWS')) exit();

class ChangePwdModel extends Model {
	protected $tableName = 'User';
	protected $_map = array('newPassword' => 'password'
		);
	protected $_validate = array(
		array('currentPassword', 'require', '原密码不能为空！', 1),
		array('password', 'require', '新密码不能为空！', 1),
		array('rePassword', 'require', '重复密码不能为空！', 1),
		array('password', '/^[\w~!@#$%^&*()_+{}:"<>?\-=[\];\',.\/]{8,16}$/', '密码格式不正确！必须由8-6位常用字符（不含空格）组成', 1, 'regex'),
		array('rePassword', 'password', '新密码与重复密码不一致！', 1, 'confirm'),
		);
	protected $_auto = array(
		array('salt', 'getSalt', 1, 'callback'),
		array('password', 'getPwd', 1, 'callback'),
		array('cptime', 'time', 1, 'function'),
		);

	protected $salt;

	function getSalt() {
		import('ORG.Util.String');
		$this -> salt = String :: randString();
		return $this -> salt;
	}

	function getPwd($data) {
		return md5(md5($data) . $this -> salt);
	}

	function getData() {
		return $this -> data;
	}
}
